<!--
  modify main content of page:
  - add section breaks
  - attach section properties
  - filter out blank sections
-->

{% assign content = include.content %}

{% assign sections = content | split: "<!-- section break -->" | array_filter %}

{% for section in sections %}
  {% assign dark = section
    | regex_scan: "<dark>(.*?)</dark>"
    | default: ""
  %}
  {% assign image = section
    | regex_scan: "<background>(.*?)</background>"
    | default: nil
  %}
  {% assign size = section
    | regex_scan: "<size>(.*?)</size>"
    | default: "page"
  %}

  <section
    class="background"
    data-size="{{ size }}"
    {% if dark == "true" or dark == "false" %}
      data-dark="{{ dark }}"
    {% endif %}
    {% if image %}
      style="--image: url('{{ image | relative_url | uri_escape }}')"
    {% endif %}
  >
    {{ section }}
  </section>
{% endfor %}
